﻿using Autofac;
using System.Reflection;

namespace WebApi.config
{
    // 批量注册服务
    public class AutofacModuleRegister:Autofac.Module
    {
        /// <summary>
        /// 重写Autofac管道Load方法 注册服务
        /// </summary>
        /// <param name="builder"></param>
        protected override void Load(ContainerBuilder builder)
        {
            // 反射程序集
            Assembly assemblyInterface = Assembly.Load("Interface");
            Assembly assemblyService = Assembly.Load("Service");

            // 注册
            builder.RegisterAssemblyTypes(assemblyInterface, assemblyService).AsImplementedInterfaces();
        }
    }
}
